package com.unirio.pm.passwordchecker;

import java.util.ArrayList;

import com.unirio.pm.interfaces.PasswordRule;
import com.unirio.pm.rules.ScoreEvaluator;


public class PasswordChecker {
	
	private ArrayList<PasswordRule> rules;
	private ScoreEvaluator evaluator;
	
	public PasswordChecker(ScoreEvaluator evaluator) {
		rules = new ArrayList<PasswordRule>();
		this.evaluator = evaluator;
	}
	
	public void addRule(PasswordRule rule) {
		this.rules.add(rule);
	}
	
	public int returnPasswordScore(String password) {
		int score = 0;
    	for(int i=0; i<rules.size(); i++) {
    		score += rules.get(i).checkRule(password);
    	}
    	return score;
	}
	
	public String returnPasswordEvaluation(int score) {
    	return this.evaluator.evaluate(score);
	}

}
